//
//  PlayButtonView.swift
//  TimMusic
//
//  Created by nkl on 2024/10/14.
//

import Foundation
import UIKit

enum PlayState {
    case pause
    case playing
}

class PlayButtonView : UIControl {
    
    var playingState : PlayState = .pause {
        didSet {
            if playingState == .pause {
                iconView.image = UIImage.init(named: "ic_play")
            }else {
                iconView.image = UIImage.init(named: "ic_pause")
            }
        }
    }
    
    lazy var iconView : UIImageView = .init(image: UIImage.init(named: "ic_pause"))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addChildren()
        makeConstraints()
    }
    
    func addChildren(){
        iconView.contentMode = .scaleAspectFill
        addSubview(iconView)
    }
    
    func makeConstraints(){
        iconView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
            make.width.height.equalTo(54)
        }
    }

    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
